package com.sunqizhong.exception;

import com.sunqizhong.entity.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice //作用：用来捕获控制器 controller层抛出的所有异常
// @ControllerAdvice
// @ResponseBody
public class GlobalExceptionHandler {
    @ExceptionHandler //指定处理何种异常
    public Result doException(Exception ex){
        log.error(ex.getMessage());
        return Result.error("出错了，请联系管理员！");
    }
}
